﻿using System;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.Revit;

namespace YArchitech.HVAC
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class AutoNumber : HYNoTranExternalCommand
	{
		public override Result HYExecute()
		{
			FrmAutoNumber frmAutoNumber = new FrmAutoNumber();
			if (frmAutoNumber.ShowDialog() == DialogResult.OK)
			{
				if (frmAutoNumber.radioButton1.Checked)
				{
					if (base.Doc.ActiveView is View3D && !((View3D)base.Doc.ActiveView).IsLocked)
					{
						YJKMessageBox.Information("在三维视图中不锁定视图无法标注管线编号!");
						return Autodesk.Revit.UI.Result.Succeeded;
					}
					new SplitPipeOperation(base.Doc, base.UiDoc, base.UiApp, this.commandData).setNum(true);
				}
				else if (frmAutoNumber.rbNumbyPipe.Checked)
				{
					if (base.Doc.ActiveView is View3D && !((View3D)base.Doc.ActiveView).IsLocked)
					{
						YJKMessageBox.Information("在三维视图中不锁定视图无法标注管线编号!");
						return Autodesk.Revit.UI.Result.Succeeded;
					}
					new SplitPipeOperation(base.Doc, base.UiDoc, base.UiApp, this.commandData).setNum(false);
				}
				else if (frmAutoNumber.radioButton2.Checked)
				{
					new SplitPipeOperation(base.Doc, base.UiDoc, base.UiApp, this.commandData).delNum();
				}
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		public override void FilterProcess()
		{
			base.FilterViewType.Add((ViewType)4);
			base.FilterProcess();
		}
	}
}
